package com.example.basic.receiver;

import android.content.Context;
import android.content.Intent;

import com.example.basic.base.BaseReceiver;

/**
 * 设备屏幕状态变化监听（息屏/亮屏/前台/后台）
 */

//TODO  使用方法待定
public class DeviceScreenStatusReceiver extends BaseReceiver {

    public DeviceScreenStatusReceiver() {
    }

    @Override
    public void register(Context context) {
        super.registerSelfNoData(context, Intent.ACTION_SCREEN_ON,Intent.ACTION_USER_PRESENT,Intent.ACTION_SCREEN_OFF);
    }

    @Override
    protected void onAction(Intent intent) {
        String result = null;
        switch (intent.getAction()) {
            case Intent.ACTION_SCREEN_OFF: result = "息屏"; break;
            case Intent.ACTION_SCREEN_ON: result = "亮屏"; break;
            case Intent.ACTION_USER_PRESENT: result = "进入HOME"; break;
            default:result = "no action"; break;
        }
    }
}
